<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>地址解析与逆地址解析</title>
    <!--引入Google Map JS文件，此处key＝“你申请道德key”-->
    <script type="text/javascript" src="http://ditu.google.cn/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAira30FR5tVprWCJ-8_WcqxSrc1zAT9YCtP2kOyoD7kBAJfliJBROJEdu9hUE13rp9a4OHneyOoW5gg"></script>

    <script type="text/javascript">
      //initMap()函数，将地图程序加入页面
      function initMap() {
        //GBrowserIsCompatible()确定Api能否兼容当前浏览器
        if (GBrowserIsCompatible()) {
          //在ID为"Gmap"的层内显示地图
          var map = new GMap2(document.getElementById("Gmap"));    
          //设置地图中心点和缩放级别
          map.setCenter(new GLatLng(36.09778, 120.37236), 12);
          //地址解析getLocations
          var geocoder = new GClientGeocoder();
          geocoder.getLocations('栈桥', function(response) {
            place = response.Placemark[0];
            point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
            marker = new GMarker(point);
            map.addOverlay(marker);
            marker.openInfoWindowHtml(getGeocodeHtml(response));
          });
       }
     }
     //组装冒泡内的HTML数据
     function getGeocodeHtml(response){
       pname = response.name;
       paddress = response.Placemark[0].address;
       plat = response.Placemark[0].Point.coordinates[1];
       plon = response.Placemark[0].Point.coordinates[0];
       return("地点："+pname+"<br />位置："+paddress+"<br />坐标："+plat+","+plon);
     }
    </script>
  </head>
  <body onload="initMap()" onunload="GUnload()">
<div id="Gmap" style="width: 600px; height: 400px"></div>
  </body>
</html>
